﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BEELab
{
    public partial class Join : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSignIn_Click(object sender, EventArgs e)
        {
            try
            {
                int InvitationID = BEELab.Logic.ProgramManagement.SessionManagement.InvitationManagement.GetInvitationIDByCode(txtCode.Text);
                int SessionID = BEELab.Logic.ProgramManagement.SessionManagement.InvitationManagement.GetSessionIDByInvitationID(InvitationID);
                if (!Global.BlockElementsDictionary.ContainsKey(SessionID))
                {
                    lbl1.Text = "Session Inactive";
                    lbl1.Visible = true;
                }
                else
                {
                    Response.Redirect("Logic/Execution/Execute.aspx?InvitationCode=" + txtCode.Text);
                }
            }
            catch (Exception)
            {
                lbl1.Text = "Bad invitation code";
                lbl1.Visible = true;
            }
        }
    }
}